/// 关注关系模型
class FollowRelationModel {
  final String id;
  final String followerId; // 关注者ID
  final String followingId; // 被关注者ID
  final DateTime createdAt;

  FollowRelationModel({
    required this.id,
    required this.followerId,
    required this.followingId,
    required this.createdAt,
  });

  /// 从 JSON 创建关注关系模型
  factory FollowRelationModel.fromJson(Map<String, dynamic> json) {
    return FollowRelationModel(
      id: json['id'] as String,
      followerId: json['followerId'] as String,
      followingId: json['followingId'] as String,
      createdAt: DateTime.parse(json['createdAt'] as String),
    );
  }

  /// 转换为 JSON
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'followerId': followerId,
      'followingId': followingId,
      'createdAt': createdAt.toIso8601String(),
    };
  }

  /// 复制关注关系模型并修改部分属性
  FollowRelationModel copyWith({
    String? id,
    String? followerId,
    String? followingId,
    DateTime? createdAt,
  }) {
    return FollowRelationModel(
      id: id ?? this.id,
      followerId: followerId ?? this.followerId,
      followingId: followingId ?? this.followingId,
      createdAt: createdAt ?? this.createdAt,
    );
  }

  @override
  String toString() {
    return 'FollowRelationModel(id: $id, followerId: $followerId, followingId: $followingId)';
  }

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;
    return other is FollowRelationModel && other.id == id;
  }

  @override
  int get hashCode => id.hashCode;
}
